/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: user
 * Date: 2023-10-10
 * Time: 18:38
 */
public class test1010 {
    void postOrderNor(TreeNode root){
        if(root == null) {
            return;
        }
        Stack<TreeNode> stack = new Stack<>();
        TreeNode cur = root;
        TreeNode prev = null;
        while (cur != null || !stack.isEmpty()) {
            while (cur != null) {
                stack.push(cur);
                cur = cur.left;
            }
            TreeNode top = stack.peek();

            if(top.right == null || top.right == prev) {
                System.out.print(top.val+" ");
                stack.pop();
                prev = top;
            }else {
                cur = top.right;
            }
        }
    }


    public int nodeSize;
    // 获取树中节点的个数
    int size(TreeNode root) {
        @@ -639,7 +664,6 @@ public class Main {
            return;
        }
    }

}

